<?php

class change_cache_path {
	
	function set_cache_path($params){
		global $CFG, $URI, $OUT;
		
		$cache_path = $params[0];
		$applied_controllers = $params[1];
		
		if(!is_array($applied_controllers))
			$applied_controllers = array($applied_controllers);
		
		//
		if( array_search($URI->rsegment(1), $applied_controllers) !== FALSE ){
			$CFG->set_item('cache_path', $cache_path);
		//Also It could be applied for a certain method
		
		}elseif( array_key_exists ($URI->rsegment(1), $applied_controllers) ){

			if( array_search($URI->rsegment(2), $applied_controllers[$URI->rsegment(1)]) !== FALSE )
				$CFG->set_item('cache_path', $cache_path);
		
		}
				
		if ($OUT->_display_cache($CFG, $URI) == TRUE)
		{
			exit;
		}
	}
	
}